<%@ page import="edu.njfu.sas.model.Student" %>
<%@ page import="edu.njfu.sas.dao.StudentDao" %>
<%@ page import="edu.njfu.sas.dao.impl.StudentDaoImpl" %><%--
  Created by IntelliJ IDEA.
  User: guzhe
  Date: 2020/12/11
  Time: 21:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
/*
* 1.获取学生信息
* 2.根据学生信息生成Student对象
* 3.调用StudentDao 对象保存学生对象到数据库中
* 4.根据保存结果，进行页面跳转
* true 跳转到liststudents页面
* false 跳转到error页面
* */
String stuno=request.getParameter("stuno");
String stuname=request.getParameter("stuname");
String classes=request.getParameter("classes");
String gender=request.getParameter("gender");
String department=request.getParameter("department");
String tel=request.getParameter("tel");
String dormno=request.getParameter("dormno");
    Student student = new Student(stuno, stuname, classes, gender, department, tel, dormno,null);
     StudentDao studentDao =new  StudentDaoImpl();
    boolean result = studentDao.saveStudent(student);
    if(result)
    {
        response.setCharacterEncoding("UTF-8");
        response.sendRedirect("liststudents.jsp");
    }else{
        response.setCharacterEncoding("UTF-8");
        response.sendRedirect("error.jsp");
    }
%>
